home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-07-11 | 24.8 KB | 1,036 lines | [TEXT/MPS ] |
- (*********************)
- (* methods for TCard *)
- (*********************)
-
- {$S ARes}
- FUNCTION TCard.GetDocument: TDesignDocument;
-
- BEGIN
- GetDocument:= fDocument;
- END; {TCard.GetDocument}
-
- {$S ARes}
- PROCEDURE TCard.SetDocument(theDocument: TDesignDocument);
-
- BEGIN
- fDocument:= theDocument;
- END; {TCard.SetDocument}
-
- {$S ARes}
- FUNCTION TCard.GetDesignView: TDesignView;
-
- BEGIN
- GetDesignView:= fDesignView;
- END; {TCard.GetDesignView}
-
- {$S ARes}
- PROCEDURE TCard.SetDesignView(theDesignView: TDesignView);
-
- BEGIN
- fDesignView:= theDesignView;
- END; {TCard.SetDesignView}
-
- {$S ARes}
- FUNCTION TCard.GetTextHandler: TTextHandler;
-
- BEGIN
- GetTextHandler:= fTextHandler;
- END; {TCard.GetTextHandler}
-
- {$S ARes}
- PROCEDURE TCard.SetTextHandler(theTextHandler: TTextHandler);
-
- BEGIN
- fTextHandler:= theTextHandler;
- END; {TCard.SetTextHandler}
-
- {$S ARes}
- FUNCTION TCard.GetEditView: TEditView;
-
- BEGIN
- GetEditView:= fEditView;
- END; {TCard.GetEditView}
-
- {$S ARes}
- PROCEDURE TCard.SetEditView(theEditView: TEditView);
-
- BEGIN
- fEditView:= theEditView;
- END; {TCard.SetEditView}
-
- {$S ARes}
- FUNCTION TCard.GetTheClass: TItem;
-
- BEGIN
- GetTheClass:= fClassName;
- END; {TCard.GetTheClass}
-
- {$S ARes}
- PROCEDURE TCard.SetTheClass(anItem: TItem);
-
- BEGIN
- fClassName:= anItem;
- END; {TCard.SetTheClass}
-
- {$S ARes}
- FUNCTION TCard.GetTheSuperClass: TItem;
-
- BEGIN
- GetTheSuperClass:= fSuperClass;
- END; {TCard.GetTheSuperClass}
-
- {$S ARes}
- PROCEDURE TCard.SetTheSuperClass(anItem: TItem);
-
- BEGIN
- fSuperClass:= anItem;
- END; {TCard.SetTheSuperClass}
-
- {$S ARes}
- FUNCTION TCard.GetNumFields: ArrayIndex;
-
- BEGIN
- GetNumFields:= fFieldList.GetSize;
- END; {TCard.GetNumFields}
-
- {$S ARes}
- FUNCTION TCard.GetNumMethods: ArrayIndex;
-
- BEGIN
- GetNumMethods:= fMethodList.GetSize;
- END; {TCard.GetNumMethods}
-
- {$S ARes}
- FUNCTION TCard.GetNumCollaborators: ArrayIndex;
-
- BEGIN
- GetNumCollaborators:= fCollaboratorList.GetSize;
- END; {TCard.GetNumCollaborators}
-
- {$S ADoCommand}
- PROCEDURE TCard.ChangeClass(theName: str255);
- VAR
- theOldName: Str255;
- BEGIN
- theOldName:= SELF.GetTheClass.GetTheName;
- fClassName.SetTheName(theName); {this filters out bad chars & adds the prefix}
- theName:= fClassName.GetTheName;
- fSimpleCardView.ChangeClassName(theName);
- fEditView.ChangeClassName(theName);
- SELF.GetDocument.ChangeNameInObjectLists(theOldName, theName);
- END; {TCard.ChangeClass}
-
- {$S ADoCommand}
- PROCEDURE TCard.ChangeSuperClass(theName: str255);
-
- BEGIN
- fSuperClass.SetTheName(theName);
- theName:= fSuperClass.GetTheName;
- fSimpleCardView.ChangeSuperClassName(theName);
- fEditView.ChangeSuperClassName(theName);
- END; {TCard.ChangeSuperClass}
-
- {$S ADoCommand}
- PROCEDURE TCard.ChangeField(theFieldItem: TFieldItem;
- theName: Str255; theType: Str255);
-
- VAR
- theItem: INTEGER;
- theFieldTextListView: TFieldTextListView;
-
- BEGIN
- theFieldItem.SetTheName(theName);
- theFieldItem.SetItemType(theType);
- theItem:=SELF.GetIndexOfField(theFieldItem);
- theFieldTextListView:=fEditView.fFieldTextListView;
- theFieldTextListView.InvalidateItem(theItem);
- SELF.GetEditView.DeselectFieldTextListView;
- END; {TCard.ChangeField}
-
- {$S ADoCommand}
- PROCEDURE TCard.ChangeMethod(theMethodItem: TMethodItem;
- theName: Str255; IsOverride: Boolean);
- VAR
- theItem: INTEGER;
- theMethodTextListView: TMethodTextListView;
-
- BEGIN
- theMethodItem.SetTheName(theName);
- theMethodItem.SetOVERRIDE(IsOverride);
- theItem:=SELF.GetIndexOfMethod(theMethodItem);
- theMethodTextListView:=fEditView.fMethodTextListView;
- theMethodTextListView.InvalidateItem(theItem);
- SELF.GetEditView.DeselectMethodTextListView;
- END; {TCard.ChangeMethod}
-
- {$S ADoCommand}
- PROCEDURE TCard.ChangeCollaborator(theCollaboratorItem: TCollaboratorItem;
- theName: Str255);
-
- VAR
- theItem: INTEGER;
- theCollaboratorTextListView: TCollaboratorTextListView;
-
- BEGIN
- theCollaboratorItem.SetTheName(theName);
- theItem:=SELF.GetIndexOfCollaborator(theCollaboratorItem);
- theCollaboratorTextListView:=fEditView.fCollaboratorTextListView;
- theCollaboratorTextListView.InvalidateItem(theItem);
- SELF.GetEditView.DeselectCollaboratorTextListView;
- END; {TCard.ChangeCollaborator}
-
- {$S ARes}
- PROCEDURE TCard.CreateSimpleView(theDesignView: TDesignView; theDesignDoc: TDesignDocument);
-
- VAR
- aSimpleView: TSimpleView;
- subviewOffset: VPoint;
- theSimpleViewList: TList;
- anItem: TItem;
- aString: str255;
-
- BEGIN
- {find the simple view list}
- theSimpleViewList:= theDesignView.GetSimpleViewList;
-
- {create the Simple card's view}
- subviewOffset:= SELF.GetLocation;
- aSimpleView:= TSimpleView(theDesignView.DoCreateViews(theDesignDoc, theDesignView,
- kSimpleViewID, subviewOffset));
- aSimpleView.SetCard(SELF);
-
- {initialize the simple view and insert it into the list}
- aSimpleView.ISimpleView;
- anItem:= SELF.GetTheClass;
- aString:= anItem.GetTheItem;
- aSimpleView.ChangeClassName(aString);
- anItem:= SELF.GetTheSuperClass;
- aString:= anItem.GetTheItem;
- aSimpleView.ChangeSuperClassName(aString);
- SELF.SetSimpleView(aSimpleView);
- theSimpleViewList.InsertLast(aSimpleView);
-
- theDesignView.AdjustSize;
- aSimpleView.ForceRedraw;
- END; {TCard.CreateSimpleView}
-
- {$S ARes}
- PROCEDURE TCard.DeleteSimpleView;
-
- VAR
- theDesignView: TDesignView;
- theSimpleView: TSimpleView;
- theSimpleViewList: TList;
-
- BEGIN
- theDesignView:= SELF.GetDesignView;
- theSimpleView:= SELF.GetSimpleView;
- theSimpleViewList:= theDesignView.GetSimpleViewList;
- theSimpleViewList.Delete(theSimpleView);
- theDesignView.RemoveSubView(theSimpleView);
- theSimpleView.Free;
- END; {TCard.DeleteSimpleView}
-
- {$S ARes}
- PROCEDURE TCard.DeleteEditView;
-
- VAR
- theWindow: TWindow;
-
- BEGIN
- IF fEditView <> NIL THEN
- BEGIN
- theWindow:= fEditView.GetWindow;
- theWindow.Close;
- theWindow.Free;
- SELF.SetEditView(NIL);
- END;
- END; {TCard.DeleteEditView}
-
- {$S ARes}
- FUNCTION TCard.GetSimpleView: TSimpleView;
-
- BEGIN
- GetSimpleView:= fSimpleCardView;
- END; {TCard.GetSimpleView}
-
- {$S ARes}
- PROCEDURE TCard.SetSimpleView(aSimpleView: TSimpleView);
-
- BEGIN
- fSimpleCardView:= aSimpleView;
- END; {TCard.SetSimpleView}
-
- {$S ARes}
- FUNCTION TCard.GetLocation: VPoint;
-
- BEGIN
- GetLocation:= fLocation;
- END; {TCard.GetLocation}
-
- {$S ARes}
- PROCEDURE TCard.SetLocation(theLocation: VPoint);
-
- BEGIN
- fLocation:= theLocation;
- END; {TCard.SetLocation}
-
- {$S ARes}
- FUNCTION TCard.GetFields: TMyList;
- BEGIN
- GetFields:= fFieldList;
- END; {TCard.GetFields}
-
- {$S ARes}
- PROCEDURE TCard.SetFields(aFieldList: TMyList);
-
- BEGIN
- fFieldList:= aFieldList;
- END; {TCard.SetFields}
-
- {$S ARes}
- FUNCTION TCard.GetMethods: TMyMethodList;
- BEGIN
- GetMethods:= fMethodList;
- END; {TCard.GetMethods}
-
- {$S ARes}
- PROCEDURE TCard.SetMethods(aMethodList: TMyMethodList);
-
- BEGIN
- fMethodList:= aMethodList;
- END; {TCard.SetMethods}
-
- {$S ARes}
- FUNCTION TCard.GetCollaborators: TMyList;
- BEGIN
- GetCollaborators:= fCollaboratorList;
- END; {TCard.GetCollaborators}
-
- {$S ARes}
- PROCEDURE TCard.SetCollaborators(aCollaboratorList: TMyList);
-
- BEGIN
- fCollaboratorList:= aCollaboratorList;
- END; {TCard.SetCollaborators}
-
- {$S ADoCommand}
- PROCEDURE TCard.AddCardToObjectLists(theCardToAdd: TCard);
-
- VAR
- theEditView: TEditView;
-
- BEGIN
- theEditView:=SELF.GetEditView;
- IF theEditView<>NIL THEN
- theEditView.AddCardToObjectLists(theCardToAdd);
- END;
-
- {$S ADoCommand}
- PROCEDURE TCard.RemoveCardFromObjectLists(theCardToRemove: TCard);
-
- VAR
- theEditView: TEditView;
-
- BEGIN
- theEditView:=SELF.GetEditView;
- IF theEditView<>NIL THEN
- theEditView.RemoveCardFromObjectLists(theCardToRemove);
- END;
-
- {$S ADoCommand}
- PROCEDURE TCard.ChangeNameInObjectLists(theOldName, theNewName: Str255);
-
- VAR
- theEditView: TEditView;
- theCollaborators: TMyList;
- theSuperClass: Str255;
-
- PROCEDURE ChangeCollaboratorName(aCollaborator: TCollaboratorItem);
-
- VAR
- theGetAccessor: TGetAccessorItem;
- theSetAccessor: TSetAccessorItem;
- theName, theCorrectName: Str255;
-
- BEGIN
- theName:=aCollaborator.GetTheItem;
- IF theName=theOldName THEN
- BEGIN
- SELF.ChangeCollaborator(aCollaborator,theNewName);
- theCorrectName:=aCollaborator.GetTheName;
- aCollaborator.GetAccessors(theGetAccessor,theSetAccessor);
- IF theGetAccessor<>NIL THEN
- SELF.ChangeMethod(theGetAccessor,theCorrectName,FALSE);
- IF theSetAccessor<>NIL THEN
- SELF.ChangeMethod(theSetAccessor,theCorrectName,FALSE);
- END;
- END;
-
- BEGIN
- theEditView:=SELF.GetEditView;
- IF theEditView<>NIL THEN
- theEditView.ChangeNameInObjectLists(theOldName, theNewName);
- theCollaborators:= SELF.GetCollaborators;
- theCollaborators.Each(ChangeCollaboratorName);
- theSuperClass:= SELF.GetTheSuperClass.GetTheItem;
- IF theSuperClass=theOldName THEN
- BEGIN
- SELF.ChangeSuperClass(theNewName);
- IF theEditView<>NIL THEN
- theEditView.DoSelectEditText(theEditView.fSuperClassNameItem, TRUE);
- END;
-
- END;
-
- {$S AOpen}
- PROCEDURE TCard.ICard(theDesignDoc: TDesignDocument; theLocation: VPoint);
-
- VAR
- aName: TItem;
- aList: TMyList;
- aMethodList: TMyMethodList;
- theNumber: str255;
- theDesignView: TDesignView;
-
- BEGIN
- NEW(aName);
- FailNil(aName);
- theNumber:= theDesignDoc.GetNumCardsStr;
- aName.IItem(SELF, Concat(kStartingClass, theNumber));
- SELF.SetTheClass(aName);
-
- NEW(aName);
- FailNil(aName);
- aName.IItem(SELF, kStartingSuperClass);
- SELF.SetTheSuperClass(aName);
-
- SELF.SetDocument(theDesignDoc);
- theDesignView:= theDesignDoc.GetDesignView;
- SELF.SetDesignView(theDesignView);
- SELF.SetLocation(theLocation);
-
- SELF.SetTextHandler(theDesignDoc.GetTextHandler);
-
- SELF.SetEditView(NIL);
-
- NEW(aList);
- FailNIL(aList);
- aList.IList;
- SELF.SetFields(aList);
-
- NEW(aMethodList);
- FailNIL(aMethodList);
- aMethodList.IList;
- SELF.SetMethods(aMethodList);
-
- NEW(aList);
- FailNIL(aList);
- aList.IList;
- SELF.SetCollaborators(aList);
-
- SELF.SetEditView(NIL);
- SELF.SetSimpleView(NIL);
- END; {TCard.ICard}
-
- {$S ADoCommand}
- FUNCTION TCard.FieldPresent(theField: TFieldItem): boolean;
-
- VAR
- theIndex: ArrayIndex;
-
- BEGIN
- theIndex:= fFieldList.GetEqualItemNo(theField);
- IF theIndex = kNotFound THEN
- FieldPresent:= false
- ELSE
- FieldPresent:= true;
- END; {TCard.FieldPresent}
-
- {$S ADoCommand}
- PROCEDURE TCard.AddFieldAtIndex(theField: TFieldItem; theIndex: ArrayIndex);
-
- BEGIN
- IF theIndex <= fFieldList.GetSize THEN
- BEGIN
- fFieldList.InsertBefore(theIndex, theField);
- IF fEditView <> NIL THEN
- fEditView.AddField(theIndex);
- END
- ELSE
- SELF.AddField(theField);
- END; {TCard.AddFieldAtIndex}
-
- {$S ARes}
- FUNCTION TCard.GetIndexOfField(theField: TFieldItem): ArrayIndex;
-
- BEGIN
- IF theField <> NIL THEN
- GetIndexOfField:= fFieldList.GetSameItemNo(theField)
- ELSE
- GetIndexOfField:= kNotFound;
- END; {TCard.GetIndexOfField}
-
- {$S ARes}
- FUNCTION TCard.GetFieldItemAtIndex(theIndex: ArrayIndex): TFieldItem;
-
- BEGIN
- GetFieldItemAtIndex:= TFieldItem(fFieldList.At(theIndex));
- END; {TCard.GetFieldItemAtIndex}
-
- {$S ADoCommand}
- PROCEDURE TCard.AddMethodAtIndex(theMethod: TMethodItem; theIndex: ArrayIndex);
-
- BEGIN
- IF theIndex <= fMethodList.GetSize THEN
- BEGIN
- fMethodList.InsertBefore(theIndex, theMethod);
- IF fEditView <> NIL THEN
- fEditView.AddMethod(theIndex);
- END
- ELSE
- SELF.AddMethod(theMethod);
- END; {TCard.AddCollaboratorAtIndex}
-
- {$S ARes}
- FUNCTION TCard.GetMethodItemAtIndex(theIndex: ArrayIndex): TMethodItem;
-
- BEGIN
- GetMethodItemAtIndex:= TMethodItem(fMethodList.At(theIndex));
- END; {TCard.GetMethodItemAtIndex}
-
- {$S ARes}
- FUNCTION TCard.GetIndexOfMethod(theMethod: TMethodItem): ArrayIndex;
-
- BEGIN
- IF theMethod <> NIL THEN
- GetIndexOfMethod:= fMethodList.GetSameItemNo(theMethod)
- ELSE
- GetIndexOfMethod:= kNotFound;
- END; {TCard.GetIndexOfMethod}
-
- {$S ADoCommand}
- PROCEDURE TCard.AddCollaboratorAtIndex(theCollaborator: TCollaboratorItem;
- theIndex: ArrayIndex);
-
- BEGIN
- IF theIndex <= fCollaboratorList.GetSize THEN
- BEGIN
- fCollaboratorList.InsertBefore(theIndex, theCollaborator);
- IF fEditView <> NIL THEN
- fEditView.AddCollaborator(theIndex);
- END
- ELSE
- SELF.AddCollaborator(theCollaborator);
- END; {TCard.AddCollaboratorAtIndex}
-
- {$S ARes}
- FUNCTION TCard.GetIndexOfCollaborator(theCollaborator: TCollaboratorItem): ArrayIndex;
-
- BEGIN
- IF theCollaborator <> NIL THEN
- GetIndexOfCollaborator:= fCollaboratorList.GetSameItemNo(theCollaborator)
- ELSE
- GetIndexOfCollaborator:= kNotFound;
- END; {TCard.GetIndexOfCollaborator}
-
- {$S ARes}
- FUNCTION TCard.GetCollaboratorItemAtIndex(theIndex: ArrayIndex): TCollaboratorItem;
-
- BEGIN
- GetCollaboratorItemAtIndex:= TCollaboratorItem(fCollaboratorList.At(theIndex));
- END; {TCard.GetCollaboratorItemAtIndex}
-
- {$S ARes}
- PROCEDURE TCard.AddField(theField: TFieldItem);
-
- BEGIN
- fFieldList.InsertLast(theField);
- IF fEditView <> NIL THEN
- fEditView.AddFieldLast;
- IF (fFieldList.GetSize = 1) AND (fCollaboratorList.GetSize = 0) THEN
- SELF.AddFieldsMethod;
- END; {TCard.AddField}
-
- {$S ARes}
- PROCEDURE TCard.AddMethod(theMethod: TMethodItem);
-
- BEGIN
- fMethodList.InsertLast(theMethod);
- IF fEditView <> NIL THEN
- fEditView.AddMethodLast;
- END; {TCard.AddMethod}
-
- {$S ARes}
- PROCEDURE TCard.AddCollaborator(theCollaborator: TCollaboratorItem);
-
- BEGIN
- fCollaboratorList.InsertLast(theCollaborator);
- IF fEditView <> NIL THEN
- fEditView.AddCollaboratorLast;
- IF (fFieldList.GetSize = 0) AND (fCollaboratorList.GetSize = 1) THEN
- SELF.AddFieldsMethod;
- END; {TCard.AddCollaborator}
-
- {$S ARes}
- PROCEDURE TCard.AddFieldsMethod;
-
- VAR
- aFieldMethodItem: TFieldsMethodItem;
-
- BEGIN
- NEW(aFieldMethodItem);
- FailNIL(aFieldMethodItem);
- aFieldMethodItem.IMethodItem(SELF, 'Fields', kOVERRIDE);
- SELF.AddMethod(aFieldMethodItem);
- END; {TCard.AddFieldsMethod}
-
- {$S ARes}
- PROCEDURE TCard.DeleteField(theField: TFieldItem);
-
- VAR
- theIndex: ArrayIndex;
- theFieldsMethodItem: TMethodItem;
-
- BEGIN
- IF theField <> NIL THEN
- BEGIN
- theIndex:= fFieldList.GetEqualItemNo(theField);
- fFieldList.Delete(theField);
- IF fEditView <> NIL THEN
- fEditView.DeleteField(theIndex);
- IF (fFieldList.GetSize = kNoItems) AND (fCollaboratorList.GetSize = kNoItems) THEN
- BEGIN
- theFieldsMethodItem:= fMethodList.FindFieldsMethod;
- IF theFieldsMethodItem <> NIL THEN
- BEGIN
- SELF.DeleteMethod(theFieldsMethodItem);
- theFieldsMethodItem.Free;
- END;
- END;
- END;
- END; {TCard.DeleteField}
-
- {$S ARes}
- PROCEDURE TCard.DeleteMethod(theMethod: TMethodItem);
-
- VAR
- theIndex: ArrayIndex;
-
- BEGIN
- IF theMethod <> NIL THEN
- BEGIN
- theIndex:= fMethodList.GetEqualItemNo(theMethod);
- fMethodList.Delete(theMethod);
- IF fEditView <> NIL THEN
- fEditView.DeleteMethod(theIndex);
- END;
- END; {TCard.DeleteMethod}
-
- {$S ARes}
- PROCEDURE TCard.DeleteCollaborator(theCollaborator: TCollaboratorItem);
-
- VAR
- theIndex: ArrayIndex;
- theFieldsMethodItem: TMethodItem;
-
- BEGIN
- IF theCollaborator <> NIL THEN
- BEGIN
- theIndex:= fCollaboratorList.GetEqualItemNo(theCollaborator);
- fCollaboratorList.Delete(TheCollaborator);
- IF fEditView <> NIL THEN
- fEditView.DeleteCollaborator(theIndex);
- IF (fFieldList.GetSize = kNoItems) AND (fCollaboratorList.GetSize = kNoItems) THEN
- BEGIN
- theFieldsMethodItem:= fMethodList.FindFieldsMethod;
- IF theFieldsMethodItem <> NIL THEN
- SELF.DeleteMethod(theFieldsMethodItem);
- END;
- END;
- END; {TCard.DeleteCollaborator}
-
- {$S ARes}
- PROCEDURE TCard.WriteFieldInterface(theTEView: TMyTEView);
-
- PROCEDURE WriteTheDeclarations(theItem: TItem);
-
- BEGIN
- theItem.WriteDeclaration(theTEView);
- END;
-
- BEGIN
- IF fFieldList.GetSize > kNoItems THEN
- BEGIN
- theTEView.WriteToMyTEView(fTextHandler.GetFieldsInterfaceStr);
- fFieldList.Each(WriteTheDeclarations);
- theTEView.WriteEndOfLine;
- END;
- END; {TCard.WriteFieldInterface}
-
-
- {$S ARes}
- PROCEDURE TCard.WriteMethodInterface(theTEView: TMyTEView);
-
- PROCEDURE WriteTheDeclarations(theItem: TItem);
-
- BEGIN
- theItem.WriteDeclaration(theTEView);
- END;
-
- BEGIN
- IF fMethodList.GetSize > kNoItems THEN
- BEGIN
- theTEView.WriteToMyTEView(fTextHandler.GetMethodsInterfaceStr);
- fMethodList.Each(WriteTheDeclarations);
- theTEView.WriteEndOfLine;
- END;
- END; {TCard.WriteMethodInterface}
-
-
- {$S ARes}
- PROCEDURE TCard.WriteCollaboratorInterface(theTEView: TMyTEView);
-
- PROCEDURE WriteTheDeclarations(theItem: TItem);
-
- BEGIN
- theItem.WriteDeclaration(theTEView);
- END;
-
- BEGIN
- IF fCollaboratorList.GetSize > kNoItems THEN
- BEGIN
- theTEView.WriteToMyTEView(fTextHandler.GetCollaboratorsInterfaceStr);
- fCollaboratorList.Each(WriteTheDeclarations);
- theTEView.WriteEndOfLine;
- END;
- END; {TCard.WriteCollaboratorInterface}
-
- {$S ARes}
- PROCEDURE TCard.WriteInlineProcedures(theTEView: TMyTEView);
-
- PROCEDURE WriteTheInlineProcedures(theMethodItem: TMethodItem);
-
- BEGIN
- theMethodItem.WriteInlineProcedures(theTEView);
- END;
-
- BEGIN
- IF fMethodList.GetSize > kNoItems THEN
- BEGIN
- fMethodList.Each(WriteTheInlineProcedures);
- END;
- END; {TCard.WriteInlineProcedures}
-
- {$S ARes}
- PROCEDURE TCard.WriteFwdClassDecl(theTEView: TMyTEView);
-
- BEGIN
- theTEView.WriteToMyTEView(fTextHandler.GetFwdClassDeclStr(SELF));
- END; {TCard.WriteFwdClassDecl}
-
-
- {$S ARes}
- PROCEDURE TCard.WriteInterface(theTEView: TMyTEView);
-
- BEGIN
- theTEView.WriteToMyTEView(fTextHandler.GetTypeDefStr(SELF));
- CASE fTextHandler.GetLanguage OF
- kInPascal :
- BEGIN
- SELF.WriteFieldInterface(theTEView);
- SELF.WriteCollaboratorInterface(theTEView);
- SELF.WriteMethodInterface(theTEView);
- theTEView.WriteToMyTEView(fTextHandler.GetEndOfTypeDefStr);
- END;
- kInCPP :
- BEGIN
- SELF.WriteMethodInterface(theTEView);
- SELF.WriteCollaboratorInterface(theTEView);
- SELF.WriteFieldInterface(theTEView);
- theTEView.WriteToMyTEView(fTextHandler.GetEndOfTypeDefStr);
- SELF.WriteInlineProcedures(theTEView);
- END;
- END; {CASE}
- END; {TCard.WriteInterface}
-
- {$S ARes}
- PROCEDURE TCard.WriteImplementation(theTEView: TMyTEView);
-
- VAR
- aClassItem: TItem;
- aString: str255;
-
- PROCEDURE WriteTheMethodCode(theMethodItem: TMethodItem);
-
- BEGIN
- theMethodItem.WriteImplementation(theTEView);
- END;
-
- BEGIN
- aClassItem:= SELF.GetTheClass;
-
- IF fMethodList.GetSize > kNoItems THEN
- BEGIN
- theTEView.WriteToMyTEView(fTextHandler.GetImplementationNoteStr(SELF));
- fMethodList.Each(WriteTheMethodCode);
- END;
- END; {TCard.WriteImplementation}
-
- {$S ARes}
- PROCEDURE TCard.TranslateTheCard(TheOldLanguage, TheNewLanguage:Integer);
-
- VAR
- TheFieldList : TMyList;
- TheTextHandler : TTextHandler;
- TheEditView: TEditView;
- ThePopUp: TPopUp;
-
- PROCEDURE TranslateTheItems(TheItem : TFieldItem);
- BEGIN
- TheTextHandler.TranslateTheItem(TheOldLanguage, TheNewLanguage, TheItem);
- END; {TranslateTheItems}
-
-
- BEGIN
- TheFieldList:=GetFields;
- TheTextHandler:=SELF.GetTextHandler;
- TheEditView:=SELF.GetEditView;
- IF TheEditView<>NIL THEN
- BEGIN
- ThePopUp:=TPopup(TheEditView.FindSubView(kItemTypeMenuID));
- TheTextHandler.SetItemTypeMenu(ThePopUp);
- END;
- TheFieldList.EACH(TranslateTheItems);
-
- END; {TCard.TranslateTheCard}
-
- {$S AWriteFile}
- FUNCTION TCard.ReturnBytes: LONGINT;
-
- {
- File structure:
- the name of our class (str255)
- the name of our super class (str255)
- the location of the card in its view (VPoint)
- the number of fields (ArrayIndex)
- each of the fields (determined by them)
- the number of methods (ArrayIndex)
- each of the methods (determined by them)
- the number of collaborators (ArrayIndex)
- each of the collaborators (determined by them)
-
- }
-
- VAR
- ourBytes: LONGINT;
-
- BEGIN
- {class and super class names, the location and the number of items in each list}
- ourBytes:= 2 * kStringSize;
- ourBytes:= ourBytes + SIZEOF(fLocation);
- ourBytes:= ourBytes + (3 * SIZEOF(ArrayIndex));
-
- ourBytes:= ourBytes + fFieldList.ReturnBytes;
- ourBytes:= ourBytes + fMethodList.ReturnBytes;
- ourBytes:= ourBytes + fCollaboratorList.ReturnBytes;
-
- ReturnBytes:= ourBytes;
- END; {TCard.ReturnBytes}
-
- {$S AReadFile}
- PROCEDURE TCard.ReadCard(aRefNum: INTEGER);
-
- {
- File structure:
- the name of our class (str255)
- the name of our super class (str255)
- the location of the card in its view (VPoint)
- the number of fields (ArrayIndex)
- each of the fields (determined by them)
- the number of methods (ArrayIndex)
- each of the methods (determined by them)
- the number of collaborators (ArrayIndex)
- each of the collaborators (determined by them)
-
- }
-
- VAR
- aLocation: VPoint;
- numItems,
- index: ArrayIndex;
- numBytes,
- ArrayIndexSize: LONGINT;
- aFieldItem: TFieldItem;
- aMethodItem: TMethodItem;
- aCollaboratorItem: TCollaboratorItem;
-
- BEGIN
- ArrayIndexSize:= SIZEOF(ArrayIndex);
-
- {the class name}
- fClassName.ReadTheItem(aRefNum, SELF);
-
- {the super class name}
- fSuperClass.ReadTheItem(aRefNum, SELF);
-
- {the location}
- numBytes:= SIZEOF(aLocation);
- FailOSErr(FSRead(aRefNum, numBytes, @aLocation));
- SELF.SetLocation(aLocation);
-
- {the fields}
- FailOSErr(FSRead(aRefNum, ArrayIndexSize, @numItems));
- FOR index:= 1 to numItems DO
- BEGIN
- NEW(aFieldItem);
- FailNIL(aFieldItem);
- aFieldItem.ReadTheItem(aRefNum, SELF); {initialization done here}
- SELF.AddField(aFieldItem);
- END;
-
- {the methods}
- FailOSErr(FSRead(aRefNum, ArrayIndexSize, @numItems));
- FOR index:= 1 to numItems DO
- BEGIN
- NEW(aMethodItem);
- FailNIL(aMethodItem);
- aMethodItem.ReadTheItem(aRefNum, SELF); {initialization done here}
- SELF.AddMethod(aMethodItem);
- END;
-
- {the collaborators}
- FailOSErr(FSRead(aRefNum, ArrayIndexSize, @numItems));
- FOR index:= 1 to numItems DO
- BEGIN
- NEW(aCollaboratorItem);
- FailNIL(aCollaboratorItem);
- aCollaboratorItem.ReadTheItem(aRefNum, SELF); {initialization done here}
- SELF.AddCollaborator(aCollaboratorItem);
- END;
- END; {TCard.ReadCard}
-
- {$S AWriteFile}
- PROCEDURE TCard.WriteCard(aRefNum: INTEGER);
-
- {
- File structure:
- the name of our class (str255)
- the name of our super class (str255)
- the location of the card in its view (VPoint)
- the number of fields (ArrayIndex)
- each of the fields (determined by them)
- the number of methods (ArrayIndex)
- each of the methods (determined by them)
- the number of collaborators (ArrayIndex)
- each of the collaborators (determined by them)
-
- }
-
- VAR
- theString: str255;
- numBytes,
- ItemSize,
- ArrayIndexSize: LONGINT;
- aLocation: VPoint;
- numFields,
- numMethods,
- numCollaborators: ArrayIndex;
-
- PROCEDURE WriteIt(theItem: TItem);
-
- BEGIN
- theItem.WriteTheItem(aRefNum);
- END; {WriteIt}
-
- BEGIN
- ArrayIndexSize:= SIZEOF(ArrayIndex);
- ItemSize:= kStringSize;
-
- {first our name}
- theString:= fClassName.GetTheItem;
- FailOSErr(FSWrite(aRefNum, ItemSize, @theString));
-
- {then our super class}
- theString:= fSuperClass.GetTheItem;
- FailOSErr(FSWrite(aRefNum, ItemSize, @theString));
-
- {now the location}
- aLocation:= SELF.GetLocation;
- numBytes:= SIZEOF(aLocation);
- FailOSErr(FSWrite(aRefNum, numBytes, @aLocation));
-
- {get all the appropriate numbers}
- numFields:= fFieldList.GetSize;
- numMethods:= fMethodList.GetNumRealMethods;
- numCollaborators:= fCollaboratorList.GetSize;
-
- {now the fields}
- FailOSErr(FSWrite(aRefNum, ArrayIndexSize, @numFields));
- IF numFields > 0 THEN
- fFieldList.Each(WriteIt);
-
- {now the methods}
- FailOSErr(FSWrite(aRefNum, ArrayIndexSize, @numMethods));
- IF numMethods > 0 THEN
- fMethodList.Each(WriteIt);
-
- {an finally, the collaborators}
- FailOSErr(FSWrite(aRefNum, ArrayIndexSize, @numCollaborators));
- IF numCollaborators > 0 THEN
- fCollaboratorList.Each(WriteIt);
- END; {TCard.WriteCard}
-
-
- {$S AClose}
- PROCEDURE TCard.Free; OVERRIDE;
-
- BEGIN
- fClassName.Free;
- fSuperClass.Free;
- fMethodList.FreeList;
- fFieldList.FreeList;
- fCollaboratorList.FreeList;
- INHERITED Free;
- END; {TCard.Free}
-
- {$ARes}
- PROCEDURE TCard.SetupFieldsMode;
-
- BEGIN
- fEditView.SetupFieldsMode;
- END; {TCard.SetupFieldsMode}
-
- {$ARes}
- PROCEDURE TCard.SetupMethodsMode;
-
- BEGIN
- fEditView.SetupMethodsMode;
- END; {TCard.SetupMethodsMode}
-
- {$ARes}
- PROCEDURE TCard.SetupCollaboratorsMode;
-
- BEGIN
- fEditView.SetupCollaboratorsMode;
- END; {TCard.SetupCollaboratorsMode}
-
- {$S AFields}
- PROCEDURE TCard.Fields(PROCEDURE DoToField(
- fieldName: Str255; fieldAddr: Ptr; fieldType: INTEGER)); OVERRIDE;
-
- BEGIN
- DoToField('TCard', NIL, bClass);
- DoToField('fClassName', @fClassName, bObject);
- DoToField('fSuperClass', @fSuperClass, bObject);
- DoToField('fDocument', @fDocument, bObject);
- DoToField('fTextHandler', @fTextHandler, bObject);
- DoToField('fDesignView', @fDesignView, bObject);
- DoToField('fEditView', @fEditView, bObject);
- DoToField('fSimpleCardView', @fSimpleCardView, bObject);
- DoToField('fLocation', @fLocation, bVPoint);
- DoToField('fFieldList', @fFieldList, bObject);
- DoToField('fMethodList', @fMethodList, bObject);
- DoToField('fCollaboratorList', @fCollaboratorList, bObject);
- INHERITED Fields(DoToField);
- END; {TCard.Fields}